package top.winshu.common.web.upload;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Date;

/**
 * 文件上传结果
 *
 * @author winshu
 * @since 2021/12/2
 **/
public class UploadResult implements Serializable {

    /**
     * 是否成功
     */
    private boolean success;

    /**
     * 消息提示
     */
    private String message;

    /**
     * 文件大小 kb
     */
    private long fileSize;

    /**
     * 上传时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date uploadTime = new Date();

    /**
     * 上下文路径
     */
    private String contextPath;

    /**
     * 文件全路径
     */
    private String fullPath;

    /**
     * 文件相对路径
     */
    private String filePath;

    /**
     * 文件名称(不带后缀)
     */
    private String fileName;

    /**
     * 文件后缀
     */
    private String suffix;

    public long getFileSize() {
        return fileSize;
    }

    public void setFileSize(long fileSize) {
        this.fileSize = fileSize;
    }

    public Date getUploadTime() {
        return uploadTime;
    }

    public void setUploadTime(Date uploadTime) {
        this.uploadTime = uploadTime;
    }

    public String getContextPath() {
        return contextPath;
    }

    public void setContextPath(String contextPath) {
        this.contextPath = contextPath;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public String getFullPath() {
        return fullPath;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public void setFullPath(String fullPath) {
        this.fullPath = fullPath;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getFullName() {
        return MessageFormat.format("{0}.{1}", getFileName(), getSuffix());
    }
}
